home *** CD-ROM | disk | FTP | other *** search
/ GFX Sensations 1 / Graphic Sensations - Volume 1.iso / tools / amiga / 3d_tools / rend10.lzh / REND1.0 / ModelUtilities / Modeler / modeler.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-06  |  1.2 KB  |  51 lines

  1. #include <types.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include "//Include/database.h"
  5.  
  6.  
  7. main(int argc, char *argv[])
  8.  
  9. {
  10.    ULONG i,j,k,numvert,numpoly,tempb;
  11.    FLOAT tempa;
  12.    FILE *fp;
  13.    
  14.    if(argc != 2) {
  15.       printf("\nUSAGE modeler <output file name>\nReads from standard in so redirect input from an ascii file.\n\n");
  16.       return(0);
  17.    }
  18.    if((fp=fopen(argv[1],"w"))!=NULL) {
  19.       printf("\nWriting file \"%s\" ...",argv[1]);
  20.       scanf("%u %u",&numvert,&numpoly);
  21.       fwrite((void *)&numvert,sizeof(ULONG),1,fp);
  22.       fwrite((void *)&numpoly,sizeof(ULONG),1,fp);
  23.       
  24.       for(i=0;i<numvert;i++) {
  25.          for(j=0;j<3;j++) {
  26.         scanf("%f",&tempa);
  27.             fwrite((void *)&tempa,sizeof(FLOAT),1,fp);
  28.      }
  29.      tempa = 1.0;
  30.      fwrite((void *)&tempa,sizeof(FLOAT),1,fp);   
  31.       }
  32.       for(i=0;i<numpoly;i++) {
  33.      scanf("%u",&tempb);
  34.      j=0;
  35.      while(tempb != 0) {
  36.         j++;
  37.         tempb-=1;            
  38.         fwrite((void *)&tempb,sizeof(ULONG),1,fp);
  39.         scanf("%u",&tempb);
  40.      }
  41.      tempb=NOVERT;
  42.      for(k=j;k<MAXPOLYVERT;k++)
  43.         fwrite((void *)&tempb,sizeof(ULONG),1,fp);
  44.       }
  45.       fclose(fp);
  46.       printf(" Done\n\n");
  47.    }
  48.    else 
  49.       printf("\nCould not open output file !\n\n");      
  50. }
  51.